export function FieldsType(value, model, label) {
  let fields
  if (value === 'input' || value === 'textarea' || value === 'number') {
    fields = {
      model: model,
      type: value,
      wrapper: {
        label: label
      },
      customize: {
        allowClear: true,
        placeholder: `请输入${label}`
      },
      decorator: {
        "initialValue": "",
        rules: [
          {
            required: true,
            message: `请输入${label}`
          }
        ]
      },
      extend: {}
    }
  } else if (value === 'autoComplete') {
    fields = {
      model: model,
      type: value,
      wrapper: {
        label: label
      },
      customize: {
        allowClear: true,
        placeholder: `请输入${label}`,
        filterOption: true,
        dataSource: [
          {
            value: '值1',
            text: '值1'
          }
        ]
      },
      decorator: {
        "initialValue": "",
        rules: [
          {
            required: true,
            message: `请输入${label}`
          }
        ]
      },
      extend: {}
    }
  } else if (value === 'select') {
    fields = {
      model: model,
      type: value,
      wrapper: {
        label: label
      },
      customize: {
        allowClear: true,
        placeholder: `请选择${label}`,
        options: [
          {
            value: 1,
            label: '选项1'
          },
          {
            value: 2,
            label: '选项2'
          }
        ]
      },
      decorator: {
        "initialValue": "",
        rules: [
          {
            required: true,
            message: `请选择${label}`
          }
        ]
      },
      extend: {}
    }
  } else if (value === 'date') {
    fields = {
      model: model,
      type: value,
      wrapper: {
        label: label
      },
      customize: {
        allowClear: true,
        placeholder: `请选择${label}`,
        format: 'YYYY-MM-DD'
      },
      decorator: {
        "initialValue": "",
        rules: [
          {
            required: true,
            message: `请选择${label}`
          }
        ]
      },
      extend: {}
    }
  } else if (value === 'upload') {
    fields = {
      model: model,
      type: value,
      wrapper: {
        label: label
      },
      customize: {
        action: '/file/api/v1/site/default/uploadImg',
        accept: '',
        listType: 'picture-card',
        multiple: true
      },
      decorator: {
        "initialValue": "",
        rules: [
          {
            required: true,
            message: `上传`
          }
        ]
      },
      extend: {
        size: 10,
        limit: 1
      }
    }
  } else if (value === 'switch') {
    fields = {
      model: model,
      type: value,
      wrapper: {
        label: label
      },
      customize: {

      },
      decorator: {
        valuePropName: "checked",
        initialValue: false
      }
    }
  }
  return fields
}

